//
//  ExtendTableViewController.m
//  EntertainmentAssistant
//
//  Created by Admin on 14-5-4.
//  Copyright (c) 2014年 xiaoyu_wu. All rights reserved.
//

#import "ExtendTableViewController.h"

@interface ExtendTableViewController ()

@end

@implementation ExtendTableViewController

@synthesize pullTableViewDelegate;
@synthesize tableStyle;

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super init];
    if (self) {
        // Custom initialization
        tableStyle = style;
    }
    return self;
}

-(id)initWithFrame:(CGRect)f style:(UITableViewStyle)style
{
    self = [super init];
    if(self)
    {
        self.frame = f;
        self.tableStyle = style;
    }
    return self;
}


- (void)loadView {
    self.view = [[UIView alloc] initWithFrame:self.frame];
    self.tableView = [[PullTableView alloc] initWithFrame:self.view.bounds style:tableStyle];
    [self.view addSubview:self.tableView];
    ((PullTableView *)(self.tableView)).pullBackgroundColor = [UIColor clearColor];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    [self setEnableRefresh:NO];
    [self setEnableLoadMore:NO];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    self.tableView.backgroundColor = [UIColor colorWithWhite:247.0/255 alpha:1];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)setPullTableViewDelegate:(id<PullTableViewDelegate>)pullDelegate
{
    pullTableViewDelegate = pullDelegate;
    ((PullTableView*)self.tableView).pullDelegate = pullDelegate;
}

- (void)setEnableRefresh:(BOOL)flag
{
    ((PullTableView*)self.tableView).enableRefresh = flag;
}

- (void)setEnableLoadMore:(BOOL)flag
{
    ((PullTableView*)self.tableView).enableLoadingMore = flag;
}

- (void)setPullRefreshDate:(NSDate *)date
{
    ((PullTableView*)self.tableView).pullLastRefreshDate = date;
}

- (void)setPullTableIsRefreshing:(BOOL)refreshing
{
    ((PullTableView*)self.tableView).pullTableIsRefreshing = refreshing;
}
- (void)setPullTableIsLoadMore:(BOOL)loadMore
{
    ((PullTableView*)self.tableView).pullTableIsLoadingMore = loadMore;
}

- (void)reloadRowIndexInSection:(int)section row:(int)row
{
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section];
    NSArray *indexPaths = [[NSArray alloc] initWithObjects:indexPath, nil];
    [self.tableView reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
}

#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 0;
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
    if(cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
    }
    return cell;
}

@end
